Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kim Bantz Rasmussen 81 posts 310 karma points
    Mar 06, 2013 @ 11:12
    Kim Bantz Rasmussen
    0

    Razor - missing '}' ?

    Hi,

    The compiler makes an error about a missing closing curly brace, but I can't see that ...

    @inherits umbraco.MacroEngines.DynamicNodeContext
    
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    @{
        Layout = "SW_Master.cshtml";
    
        string tagToFind = Request.QueryString["tag"];
        var locations = Model.Content.AncestorOrSelf().DescendantsOrSelf().Where("tags != \"\"");
    }
    
    @if(tagToFind != null) {
    
        foreach (var node in locations) {
    
            string[] tags = @node.tags.ToString().Split(',');
    
            if (tags.Contains(tagToFind)) {
    
                @node.Url
    
            }
    
        }   
    } else {
    
        <p>No tag!</p>
    
    } 

    I have Umbraco 6 :) 

    Best regards
    Kim

  • Rich Green 2246 posts 4008 karma points
    Mar 06, 2013 @ 11:21
    Rich Green
    0

    Hey Kim,

    What about

     

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @inheritsUmbraco.Web.Mvc.UmbracoTemplatePage

    @{
       
    Layout="SW_Master.cshtml";
           
       
    string tagToFind =Request.QueryString["tag"];
       
    var locations =Model.Content.AncestorOrSelf().DescendantsOrSelf().Where("tags != \"\"");

    if(tagToFind !=null){
           
    foreach(var node in locations){

                   
    string[] tags =@node.tags.ToString().Split(',');
                   
                   
    if(tags.Contains(tagToFind)){@node.Url}
                   
           
    }  
    }   
    else{<p>No tag!</p>}

     

  • Kim Bantz Rasmussen 81 posts 310 karma points
    Mar 06, 2013 @ 11:38
    Kim Bantz Rasmussen
    0

    Hi Rich,

    Thank you, but still the same error.

    Could it be something else coursing the error? I'am not very found of this line:

     var locations = Model.Content.AncestorOrSelf().DescendantsOrSelf().Where("tags != \"\"");

    Best regards
    Kim 

  • Rich Green 2246 posts 4008 karma points
    Mar 06, 2013 @ 11:42
    Rich Green
    0

    Hey Kim,

    I'd comment out some lines until you find the error, or open in Visual Studio which should give you some visual clues

    Rich

  • Kim Bantz Rasmussen 81 posts 310 karma points
    Mar 06, 2013 @ 12:59
    Kim Bantz Rasmussen
    0

    Hi Rich,

    Thank you again! I have found the line that's makes the error!

    @{
       string tagToFind = Request.QueryString["tag"];
       var locations = Model.Content.AncestorOrSelf().DescendantsOrSelf().Where("tags != \"\"");
    }
    
    
    @if(tagToFind != null) {
    
            foreach (var node in locations){
    
            @* ------------------  This line is my problem: --------------------- *@
                    string[] tags = @node.tags.ToString().Split(',');
    
                    if (tags.Contains(tagToFind)) {
                            @node.Url
                    }
    
            }       
    }else {
            <p>No tag!</p>
    }  

     

  • kim Thomsen 59 posts 277 karma points
    Mar 06, 2013 @ 13:06
    kim Thomsen
    101

    Have you tryed removing the @ infront of node

    @{
       
    string tagToFind =Request.QueryString["tag"];
       
    var locations =Model.Content.AncestorOrSelf().DescendantsOrSelf().Where("tags != \"\"");
    }


    @if(tagToFind !=null){
           
           
    foreach(var node in locations){
                           
                   
    @*------------------  This line ismy problem:---------------------*@
                   
    string[] tags =node.tags.ToString().Split(',');
                   
                   
    if(tags.Contains(tagToFind)){
                           
    @node.Url
                   
    }
                   
           
    }      
    }else{
           
    <p>No tag!p>
    }  
  • Rich Green 2246 posts 4008 karma points
    Mar 06, 2013 @ 13:07
    Rich Green
    0

    As Kim above says :)

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Mar 06, 2013 @ 13:09
    Jeroen Breuer
    1

    It's a breaking change in v6 :-) http://issues.umbraco.org/issue/U4-1143#comment=67-4333

    Jeroen

  • Kim Bantz Rasmussen 81 posts 310 karma points
    Mar 06, 2013 @ 13:24
    Kim Bantz Rasmussen
    0

    Great! 

    Thank you all for your help!

    Working code:

    @{
       string tagToFind = Request.QueryString["tag"];
       var locations = Model.AncestorOrSelf().DescendantsOrSelf().Where("tags != \"\"");
    }
    
    
    @if(tagToFind != null) {
    
            foreach (var node in locations){
    
                    string[] tags = node.tags.ToString().Split(',');
    
                    if (tags.Contains(tagToFind)) {
                            @node.Url
                    }
    
            }       
    }else {
            <p>No tag!</p>
    }

    Best regards
    Kim 

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies